<!--
 * @Author: zi.yang
 * @Date: 2021-03-11 23:54:18
 * @LastEditors: zi.yang
 * @LastEditTime: 2021-03-12 00:11:32
 * @Description: In User Settings Edit
 * @FilePath: \vue-music\src\components\state2\test-toref.vue
-->

<template>
  <div>toRef 测试 ： {{ count }}</div>
</template>

<script>
import { reactive, toRef } from '@vue/composition-api';

export default {
  name: 'test-toref',
  setup() {
    const state = reactive({
      count: 0,
    });

    // toRefs 就是把普通的数据，转成 ref() 方法所对应的响应式数据
    const { count } = toRef(state, 'count');

    setTimeout(() => {
      state.count += 999;
    }, 1000);

    return { count };
  },
};
</script>

<style scoped></style>
